﻿var roleId = request('roleId');
var saveUrl = top.contentPath + '/setquestionsubject/save';
$(function () {
	$(".center-Panel").height($(window).height() - 40);
	GetMember();
});
//加载成员
function GetMember() {
	var data = JSON.parse(subjectInfo);
	var _html = "";
	$.each(data, function (i) {
		var row = data[i];
		var imgName = "UserCard01.png";
		var active = "";
		if (row.checked == 1) {
			active = "active";
		}
		_html += '<div class="card-box ' + row.question + ' ' + active + '">';
		_html += '    <div id="' + row.userid + '" class="card-box-content">';
		_html += '        <p style="width:auto;white-space:normal;">' + row.question + '</p>';
		_html += '    </div><i></i>';
		_html += '</div>';
	});
	$(".gridPanel").html(_html);
	$(".card-box").click(function () {
		if (!$(this).hasClass("active")) {
			$(this).addClass("active")
		} else {
			$(this).removeClass("active")
		}
	})
	//模糊查询用户（注：这个方法是理由jquery查询）
	$("#txt_TreeKeyword").keyup(function () {
		var value = $(this).val();
		if (value != "") {
			window.setTimeout(function () {
				$(".card-box")
				.hide()
				.filter(":contains('" + (value) + "')")
				.show();
			}, 200);
		} else {
			$(".card-box").show();
		}
	}).keyup();
}
//保存表单
function AcceptClick() {
	var userIds = [];
	$('.gridPanel .active .card-box-content').each(function () {
		userIds.push($(this).attr('id'));
	});
	var postData = $("#form1").GetWebControls();
	postData["sqid"] = $('#sqid').val();
	postData["ids"] = String(userIds)
	$.SaveForm({
		url: saveUrl,
		param: postData,
		loading: "正在保存数据...",
		success: function () {
			$.currentIframe().$("#gridTable").trigger("reloadGrid");
		}
	})
}